home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / Events.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  9KB  |  338 lines

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. */
  18. #ifndef __EVENTS__
  19. #define __EVENTS__
  20.  
  21. #ifndef __OSUTILS__
  22. #include <OSUtils.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __TYPES__
  28. #include <Types.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT_SUPPORTED
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_ALIGN_SUPPORTED
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. typedef UInt16 EventKind;
  44. typedef UInt16 EventMask;
  45.  
  46. enum {
  47.     nullEvent                    = 0,
  48.     mouseDown                    = 1,
  49.     mouseUp                        = 2,
  50.     keyDown                        = 3,
  51.     keyUp                        = 4,
  52.     autoKey                        = 5,
  53.     updateEvt                    = 6,
  54.     diskEvt                        = 7,
  55.     activateEvt                    = 8,
  56.     osEvt                        = 15,
  57.     kHighLevelEvent                = 23,
  58.     mDownMask                    = 1 << mouseDown,                /* mouse button pressed*/
  59.     mUpMask                        = 1 << mouseUp,                    /* mouse button released*/
  60.     keyDownMask                    = 1 << keyDown,                    /* key pressed*/
  61.     keyUpMask                    = 1 << keyUp,                    /* key released*/
  62.     autoKeyMask                    = 1 << autoKey,                    /* key repeatedly held down*/
  63.     updateMask                    = 1 << updateEvt,                /* window needs updating*/
  64.     diskMask                    = 1 << diskEvt,                    /* disk inserted*/
  65.     activMask                    = 1 << activateEvt,                /* activate/deactivate window*/
  66.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents)*/
  67.     osMask                        = 1 << osEvt,                    /* operating system events (suspend, resume)*/
  68.     everyEvent                    = 0xFFFF                        /* all of the above*/
  69. };
  70.  
  71.  
  72. enum {
  73.     charCodeMask                = 0x000000FF,
  74.     keyCodeMask                    = 0x0000FF00,
  75.     adbAddrMask                    = 0x00FF0000,
  76.     osEvtMessageMask            = 0xFF000000,                    /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  77.     mouseMovedMessage            = 0x00FA,
  78.     suspendResumeMessage        = 0x0001,
  79.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  80.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change*/
  81. };
  82.  
  83. typedef UInt16 EventModifiers;
  84.  
  85. enum {
  86.                                                                 /* modifiers */
  87.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown)*/
  88.     btnStateBit                    = 7,                            /* state of button?*/
  89.     cmdKeyBit                    = 8,                            /* command key down?*/
  90.     shiftKeyBit                    = 9,                            /* shift key down?*/
  91.     alphaLockBit                = 10,                            /* alpha lock down?*/
  92.     optionKeyBit                = 11,                            /* option key down?*/
  93.     controlKeyBit                = 12,                            /* control key down?*/
  94.     rightShiftKeyBit            = 13,                            /* right shift key down?*/
  95.     rightOptionKeyBit            = 14,                            /* right Option key down?*/
  96.     rightControlKeyBit            = 15,                            /* right Control key down?*/
  97.     activeFlag                    = 1 << activeFlagBit,
  98.     btnState                    = 1 << btnStateBit,
  99.     cmdKey                        = 1 << cmdKeyBit,
  100.     shiftKey                    = 1 << shiftKeyBit,
  101.     alphaLock                    = 1 << alphaLockBit,
  102.     optionKey                    = 1 << optionKeyBit,
  103.     controlKey                    = 1 << controlKeyBit,
  104.     rightShiftKey                = 1 << rightShiftKeyBit,
  105.     rightOptionKey                = 1 << rightOptionKeyBit,
  106.     rightControlKey                = 1 << rightControlKeyBit
  107. };
  108.  
  109.  
  110. enum {
  111.     kNullCharCode                = 0,
  112.     kHomeCharCode                = 1,
  113.     kEnterCharCode                = 3,
  114.     kEndCharCode                = 4,
  115.     kHelpCharCode                = 5,
  116.     kBellCharCode                = 7,
  117.     kBackspaceCharCode            = 8,
  118.     kTabCharCode                = 9,
  119.     kLineFeedCharCode            = 10,
  120.     kVerticalTabCharCode        = 11,
  121.     kPageUpCharCode                = 11,
  122.     kFormFeedCharCode            = 12,
  123.     kPageDownCharCode            = 12,
  124.     kReturnCharCode                = 13,
  125.     kFunctionKeyCharCode        = 16,
  126.     kEscapeCharCode                = 27,
  127.     kClearCharCode                = 27,
  128.     kLeftArrowCharCode            = 28,
  129.     kRightArrowCharCode            = 29,
  130.     kUpArrowCharCode            = 30,
  131.     kDownArrowCharCode            = 31,
  132.     kDeleteCharCode                = 127,
  133.     kNonBreakingSpaceCharCode    = 202
  134. };
  135.  
  136. struct EventRecord {
  137.     EventKind                         what;
  138.     UInt32                             message;
  139.     UInt32                             when;
  140.     Point                             where;
  141.     EventModifiers                     modifiers;
  142. };
  143. typedef struct EventRecord EventRecord;
  144.  
  145. typedef UInt32 KeyMap[4];
  146. #if FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE
  147. typedef pascal void (*FKEYProcPtr)(void );
  148.  
  149. #if GENERATINGCFM
  150. typedef UniversalProcPtr FKEYUPP;
  151. #else
  152. typedef FKEYProcPtr FKEYUPP;
  153. #endif
  154.  
  155. enum {
  156.     uppFKEYProcInfo = kPascalStackBased
  157. };
  158.  
  159. #if GENERATINGCFM
  160. #define NewFKEYProc(userRoutine)        \
  161.         (FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  162. #else
  163. #define NewFKEYProc(userRoutine)        \
  164.         ((FKEYUPP) (userRoutine))
  165. #endif
  166.  
  167. #if GENERATINGCFM
  168. #define CallFKEYProc(userRoutine)        \
  169.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFKEYProcInfo)
  170. #else
  171. #define CallFKEYProc(userRoutine)        \
  172.         (*(userRoutine))()
  173. #endif
  174. extern pascal void GetMouse(Point *mouseLoc)
  175.  ONEWORDINLINE(0xA972);
  176.  
  177. extern pascal Boolean Button(void )
  178.  ONEWORDINLINE(0xA974);
  179.  
  180. extern pascal Boolean StillDown(void )
  181.  ONEWORDINLINE(0xA973);
  182.  
  183. extern pascal Boolean WaitMouseUp(void )
  184.  ONEWORDINLINE(0xA977);
  185.  
  186. extern pascal UInt32 TickCount(void )
  187.  ONEWORDINLINE(0xA975);
  188.  
  189. extern pascal void GetKeys(KeyMap theKeys)
  190.  ONEWORDINLINE(0xA976);
  191.  
  192. extern pascal UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
  193.  ONEWORDINLINE(0xA9C3);
  194.  
  195. extern pascal UInt32 GetCaretTime(void)
  196.  TWOWORDINLINE(0x2EB8, 0x02F4);
  197.  
  198. #endif
  199. #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
  200. /* Obsolete event types & masks */
  201.  
  202. enum {
  203.     networkEvt                    = 10,
  204.     driverEvt                    = 11,
  205.     app1Evt                        = 12,
  206.     app2Evt                        = 13,
  207.     app3Evt                        = 14,
  208.     app4Evt                        = 15,
  209.     networkMask                    = 0x0400,
  210.     driverMask                    = 0x0800,
  211.     app1Mask                    = 0x1000,
  212.     app2Mask                    = 0x2000,
  213.     app3Mask                    = 0x4000,
  214.     app4Mask                    = 0x8000
  215. };
  216.  
  217. struct EvQEl {
  218.     QElemPtr                         qLink;
  219.     SInt16                             qType;
  220.     EventKind                         evtQWhat;                    /* this part is identical to the EventRecord as defined above */
  221.     UInt32                             evtQMessage;
  222.     UInt32                             evtQWhen;
  223.     Point                             evtQWhere;
  224.     EventModifiers                     evtQModifiers;
  225. };
  226. typedef struct EvQEl EvQEl;
  227.  
  228. typedef EvQEl *EvQElPtr;
  229. /*
  230.         This ProcPtr uses register based parameters on the 68k and cannot
  231.         be written in or called from a high-level language without the help of
  232.         mixed mode or assembly glue.
  233.  
  234.             typedef pascal void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
  235.  
  236. */
  237.  
  238. #if GENERATINGCFM
  239. typedef UniversalProcPtr GetNextEventFilterUPP;
  240. #else
  241. typedef Register68kProcPtr GetNextEventFilterUPP;
  242. #endif
  243.  
  244. enum {
  245.     uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO(11)
  246. };
  247.  
  248. #if GENERATINGCFM
  249. #define NewGetNextEventFilterProc(userRoutine)        \
  250.         (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  251. #else
  252. #define NewGetNextEventFilterProc(userRoutine)        \
  253.         ((GetNextEventFilterUPP) (userRoutine))
  254. #endif
  255.  
  256. #if GENERATINGCFM
  257. #define CallGetNextEventFilterProc(userRoutine, theEvent, result)        \
  258.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  259. #else
  260. /* (*GetNextEventFilterUPP) cannot be called from a high-level language without the Mixed Mode Manager */
  261. #endif
  262. typedef GetNextEventFilterUPP GNEFilterUPP;
  263. extern pascal QHdrPtr GetEvQHdr(void )
  264.  THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  265.  
  266. extern pascal UInt32 GetDblTime(void)
  267.  TWOWORDINLINE(0x2EB8, 0x02F0);
  268.  
  269. extern pascal void SetEventMask(EventMask value)
  270.  TWOWORDINLINE(0x31DF, 0x0144);
  271.  
  272.  
  273. #if GENERATING68K && !GENERATINGCFM
  274. #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  275. #endif
  276. extern pascal OSErr PPostEvent(EventKind eventCode, UInt32 eventMsg, EvQElPtr *qEl)
  277.  TWOWORDINLINE(0xA12F, 0x2288);
  278.  
  279. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  280. extern pascal Boolean GetNextEvent(EventMask eventMask, EventRecord *theEvent)
  281.  ONEWORDINLINE(0xA970);
  282.  
  283. extern pascal Boolean WaitNextEvent(EventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
  284.  ONEWORDINLINE(0xA860);
  285.  
  286. extern pascal Boolean EventAvail(EventMask eventMask, EventRecord *theEvent)
  287.  ONEWORDINLINE(0xA971);
  288.  
  289.  
  290. #if GENERATING68K && !GENERATINGCFM
  291. #pragma parameter __D0 PostEvent(__A0, __D0)
  292. #endif
  293. extern pascal OSErr PostEvent(EventKind eventNum, UInt32 eventMsg)
  294.  ONEWORDINLINE(0xA02F);
  295.  
  296.  
  297. #if GENERATING68K && !GENERATINGCFM
  298. #pragma parameter __D0 OSEventAvail(__D0, __A0)
  299. #endif
  300. extern pascal Boolean OSEventAvail(EventMask mask, EventRecord *theEvent)
  301.  TWOWORDINLINE(0xA030, 0x5240);
  302.  
  303.  
  304. #if GENERATING68K && !GENERATINGCFM
  305. #pragma parameter __D0 GetOSEvent(__D0, __A0)
  306. #endif
  307. extern pascal Boolean GetOSEvent(EventMask mask, EventRecord *theEvent)
  308.  TWOWORDINLINE(0xA031, 0x5240);
  309.  
  310. extern pascal void FlushEvents(EventMask whichMask, EventMask stopMask)
  311.  TWOWORDINLINE(0x201F, 0xA032);
  312.  
  313. extern pascal void SystemClick(const EventRecord *theEvent, WindowRef theWindow)
  314.  ONEWORDINLINE(0xA9B3);
  315.  
  316. extern pascal void SystemTask(void )
  317.  ONEWORDINLINE(0xA9B4);
  318.  
  319. extern pascal Boolean SystemEvent(const EventRecord *theEvent)
  320.  ONEWORDINLINE(0xA9B2);
  321.  
  322. #endif
  323.  
  324. #if PRAGMA_ALIGN_SUPPORTED
  325. #pragma options align=reset
  326. #endif
  327.  
  328. #if PRAGMA_IMPORT_SUPPORTED
  329. #pragma import off
  330. #endif
  331.  
  332. #ifdef __cplusplus
  333. }
  334. #endif
  335.  
  336. #endif /* __EVENTS__ */
  337.  
  338.